const cacheMap = {
  station_DD_cluster: [],
  station_PP_cluster: [],
  station_QT_cluster: [],
  station_RR_cluster: [],
  station_ZQ_cluster: [],
  station_ZZ_cluster: []
}
const YsqxxCacheMap = {
  ysqxx_SWSW_cluster: [],
  ysqxx_SQ_cluster: [],
  ysqxx_SZ_cluster: [],
  ysqxx_DXS_cluster: [],
  ysqxx_CITY_deep_cluster: [], // 地下水深层
  ysqxx_CITY_shallow_cluster: [] // 地下水浅层

}

const textColorMap = {
  station_DD_cluster: '#ffdce5',
  station_PP_cluster: '#DCFFDF',
  station_QT_cluster: '#DCFFF7',
  station_RR_cluster: '#ffdce5',
  station_ZQ_cluster: '#ffdce5',
  station_ZZ_cluster: '#FFE7DC'
}

const clusterLayerStyleMap = {}

for (const key in cacheMap) {
  if (Object.hasOwnProperty.call(cacheMap, key)) {
    const element = cacheMap[key]
    clusterLayerStyleMap[key + '_func'] = function (size) {
      if (!element[size]) {
        element[size] = new window.ol.style.Style({
          image: new window.ol.style.Icon({
            offset: [0, 0],
            scale: 1,
            src: require(`@/assets/images/map/${key}.png`)
          }),
          text: new window.ol.style.Text({
            font: 'bold 0.8rem sans-serif',
            text: (size !== undefined && size !== null) ? size.toString() : '',
            fill: new window.ol.style.Fill({
              color: textColorMap[key]
            }),
            offsetY: 7
          })
        })
      }
      return element[size]
    }
  }
}

for (const key in YsqxxCacheMap) {
  if (Object.hasOwnProperty.call(YsqxxCacheMap, key)) {
    const element = YsqxxCacheMap[key]
    clusterLayerStyleMap[key + '_func'] = function (size) {
      if (!element[size]) {
        element[size] = new window.ol.style.Style({
          image: new window.ol.style.Icon({
            offset: [0, 0],
            scale: 1,
            src: require(`@/assets/images/ysqxx/map/${key}.png`)
          }),
          text: new window.ol.style.Text({
            font: 'bold 0.6rem YouSheBiaoTiHei sans-serif',
            text: (size !== undefined && size !== null) ? size.toString() : '',
            fill: new window.ol.style.Fill({
              color: '#ffffff'
            }),
            offsetY: 16
          })
        })
      }
      return element[size]
    }
  }
}

export { clusterLayerStyleMap }
